package com.zq.download;

import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;

import java.io.File;
import java.util.concurrent.Executors;

/**
 * Created by zhangqiang on 17-6-21.
 */

public class DownloadManager {

    private static final DownloadManager downloadManager = new DownloadManager();


    public static DownloadManager get() {
        return downloadManager;
    }

    public void download(String url, SQLiteOpenHelper sqLiteOpenHelper){

        File saveDir = new File(Environment.getExternalStorageDirectory(),"download");
        if(!saveDir.exists() && !saveDir.mkdir()){
            return;
        }

        File partSaveDir = new File(saveDir,"part");
        if(!partSaveDir.exists() && !partSaveDir.mkdir()){
            return;
        }

        new DownloadTask(url,
                1,
                saveDir.getAbsolutePath(),
                partSaveDir.getAbsolutePath(),sqLiteOpenHelper).start();
    }
}
